﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using CSharpDesign.DAL;
using CSharpDesign.Scripts;

namespace CSharpDesign.Admin
{
    public partial class TianJiaShangPin : System.Web.UI.Page
    {
        SqlHelper data = new SqlHelper();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.DataSource = CommonHelper.GetDataByAdapter("select * from ShangPinFenLei");
                DropDownList1.DataValueField = "id";
                DropDownList1.DataTextField = "name";
                DropDownList1.DataBind();
            }
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            string res;
            upload upload = new upload();
            res = upload.Up(file1, "../files/");
            this.Label1.Visible = true;
            this.Label1.Text = upload.Resup[Convert.ToInt32(res)];
            this.pic.Text = upload.s;
            Image1.ImageUrl = "../files/" + pic.Text;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            CommonHelper.ExecuteSql("insert into ShangPin (SPName,ShangPinFenLeiID,ShangPinFenLeiName,SPNum,SPPhoto,SPPrice,SPIntroduce,SPXingHao,SPGuiGe,SPDanWei)values('" + title.Text + "','" + DropDownList1.SelectedValue + "','" + DropDownList1.SelectedItem.Text + "','" + TextBox3.Text + "','" + pic.Text + "','" + TextBox2.Text + "','" + content1.Value + "','" + TextBox1.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "') ");
            Alert.AlertAndRedirect("添加成功", "TianJiaShangPin.aspx");
        }
    }
}